import type { PiniaPlugin } from 'pinia'

export const resetPlugin: PiniaPlugin = ({ store }) => {
  const initialState = JSON.parse(JSON.stringify(store.$state))
  store.$reset = () => {
    store.$patch(($state) => Object.assign($state, initialState))
  }
}
